function success(data: Object) {
  return {
    code: 0,
    data: data,
    msg: '成功',
  };
}

function fail(msg: String) {
  return {
    code: 403,
    data: null,
    msg: msg,
  };
}

export default {
  'POST /api/unifiedorder/native': (req, res) => {
    console.log(req.body);
    const { amount } = req.body;
    if (isNaN(Number(amount))) {
      res.send(fail('输入金额正确金额'));
      return;
    }
    if (amount > 0.1) {
      res.send(fail('土豪，输入金额请小于0.1元'));
      return;
    }
    res.send(
      success({
        return_code: 'SUCCESS',
        return_msg: 'OK',
        result_code: 'SUCCESS',
        mch_id: '1603243310',
        appid: 'wx6a1e3ce1f184779a',
        nonce_str: 'VV1LAST3ezdClvSg',
        sign: '3011F22A6C06F63D3A8A3F757EFDCD3EC9B72BFA5F25D4487A931A4164919FA2',
        prepay_id: 'wx2723273383647856d81f7eec4ac5f50000',
        trade_type: 'NATIVE',
        code_url: 'weixin://wxpay/bizpayurl?pr=X1e0TMlzz',
      }),
    );
  },
  'POST /api/unifiedorder/h5': (req, res) => {
    console.log(req.body);
    const { amount } = req.body;
    if (isNaN(Number(amount))) {
      res.send(fail('输入金额正确金额'));
      return;
    }
    if (amount > 0.1) {
      res.send(fail('土豪，输入金额请小于0.1元'));
      return;
    }
    res.send(
      success({
        return_code: 'SUCCESS',
        return_msg: 'OK',
        appid: 'wx2421b1c4370ec43b',
        mch_id: '10000100',
        nonce_str: 'IITRi8Iabbblz1Jc',
        sign: '7921E432F65EB8ED0CE9755F0E86D72F',
        result_code: 'SUCCESS',
        prepay_id: 'wx201411101639507cbf6ffd8b0779950874',
        trade_type: 'MWEB',
        mweb_url:
          'https://wx.tenpay.com/cgi-bin/mmpayweb-bin/checkmweb?prepay_id=wx2016121516420242444321ca0631331346&package=1405458241',
      }),
    );
  },
};
